<template>
	<view class="wrap">
		<view class="item" v-for="(item, index) in storeList" :key="item.applicableUnitNo">
			<store-cell 
			 :isLocation="index == 0 ? 1 : 0"
			 :storeName="item.applicableUnit"
			 :storeAddress="item.unitAddress"
			 :distance="item.distance"
			 :phone="item.unitPhone"
			 :latitude="item.unitLat"
			 :longitude="item.unitLon"
		  ></store-cell>
		</view>
		
	</view>
</template>

<script>
	import storeCell from '../../components/coupon/store-cell.vue'
	import {unitList} from '../../common/api.js'
	export default {
		components: {
			storeCell
		},
		data() {
			return {
				bizNo: '',
				latitude: '',
				longitude: '',
				storeList : []
			}
		},
		onLoad(op) {
			this.bizNo = op.businessId;
			console.log(this.bizNo);
			this.getLocation();
		},
		
		methods: {
			
			//获取定位信息
			getLocation() {
				uni.getLocation({
				    type: 'wgs84',
				    success:  (res => {
							this.latitude = res.latitude;
							this.longitude = res.longitude;
							this.getStore();
						}),
					fail:(e=>{
						this.getStore();
					})
				});
			},
			
			getStore() {
				let that = this;
				unitList({
					bizNo : that.bizNo,
					lon : this.longitude,
					lat : this.latitude,
				}).then(res => {
					this.storeList = res;
				})
			}
		}
	}
</script>
  
<style lang="scss" scoped>
.wrap {
	padding: 10upx 25upx;
	.item {
		margin-top: 30upx;
	}
}



</style>
